import ipaddress
import threading
import warnings
from scapy.layers.l2 import ARP
from scapy.sendrecv import sr1
warnings.filterwarnings("ignore")
def arp_scan_ip(pdst="127.0.0.1", iface="VMware Virtual Ethernet Adapter for VMnet8"):
    send_pkg = ARP(pdst=pdst)
    result_pkg = sr1(send_pkg, iface=iface, verbose=False, timeout=0.1)
    if result_pkg:
        psrc = result_pkg.sprintf("%ARP.psrc%")
        pmack = result_pkg.sprintf("%ARP.hwsrc%")
        print(f"[+] {psrc} | {pmack} 存活")
def run_ip(host,iface):
    # iface = "Realtek USB GbE Family Controller #2"
    threads = []
    # 结构IP网段地址 明确起始与结束 生成一个可以迭代的IP地址列表
    for ip in ipaddress.IPv4Network(host):
        t = threading.Thread(target=arp_scan_ip, args=(str(ip), iface))
        t.start()
        threads.append(t)
    for t in threads:
        t.join()